<%-- 
    Document   : default
    Created on : 2009-7-11, 23:07:13
    Author     : think
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script src="javascripts/prototype.js" language="JavaScript" type="text/javascript"></script>
        <script src="javascripts/scriptaculous.js" language="JavaScript" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" media="screen" href="http://l.yimg.com/hr/1126/del-frontend-min.css">

        <script>
            function start_RSRunner_monintor(){
                var m1 = new Ajax.PeriodicalUpdater(
                "tsrunner_state",'GetRunnerStateServlet'
                ,{method:'get',frequency:1, decay:0});
            }

            function start_jobQueue_monintor(){
                var m2 = new Ajax.PeriodicalUpdater(
                "jobqueue_state",'getQueuedJobs'
                ,{method:'get',frequency:5, decay:0});

            }

            function  start_vm_monintor(){
                var m3 = new Ajax.PeriodicalUpdater(
                "vm_list","VMStateServlet",
                {method:'get',frequency:30, decay:0}
            )

            }

            function startTSRunner(){
                new Ajax.Request("switchTSRunner?switch=on",{method:'get'});
            }

            function stopTSRunner(){
                new Ajax.Request("switchTSRunner?switch=off",{method:'get'});
            }

            document.observe('dom:loaded', function() {
                start_RSRunner_monintor();
                start_runningjobs_monitor();
                start_jobQueue_monintor();
                start_vm_monintor();
            });

            function start_runningjobs_monitor(){
                new Ajax.PeriodicalUpdater(
                "runningjob_state",'getRunningTS'
                ,{method:'get',frequency:5, decay:0});
            }

            function setBuildName(e){
                var keynum
                var cmd
                if(window.event) // IE
                {
                    keynum = e.keyCode
                }
                else if(e.which) // Netscape/Firefox/Opera
                {
                    keynum = e.which
                }
                if(keynum==13){
                    //alert($("command").getValue());

                    var text = $('buildname').getValue();
                    new Ajax.Updater("confirm","setBuildName?build="+text,{method:'get'});
                    new Effect.Highlight('confirm');
                }
            }

            function parseCommand(e)
            {
                var keynum
                var cmd
                if(window.event) // IE
                {
                    keynum = e.keyCode
                }
                else if(e.which) // Netscape/Firefox/Opera
                {
                    keynum = e.which
                }
                if(keynum==13){
                    //alert($("command").getValue());

                    var text = $('command').getValue();
                    new Ajax.Updater("result","ParseCommand?cmd="+text,{method:'get'});
                    new Effect.Highlight('result');

                }
            }
        </script>
    </head>
    <body>
        <input id="buildname" type="text" value="build0" onkeydown="setBuildName(event)" />
        <br><div id="confirm"></div><br>
        <h1>Test Script Runner state:</h1>
        <div id="tsrunner_state" ></div>
        <br>
        <h2>Running Test script:</h2>
        <div id="runningjob_state"></div>
        <br>
        <h2>Queued Test script:</h2>
        <div id="jobqueue_state"></div>
        <br>
        <h2>Online VM</h2>
        <div id="vm_list"></div>
        <br>
        <h2>TSRunner state:</h2>
        <div id="rsrunner_state1" ></div>
        <br>
        Command:
        <input id="command" type="text" onkeydown="parseCommand(event)" />
        <div id="result"></div>
    </body>
</html>
